package org.geeks.gsflyingsaucer.func.thymeleaf;

import java.util.Locale;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.thymeleaf.TemplateEngine;
import org.thymeleaf.context.Context;
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver;

@Slf4j
public class ThymeleafT {

  @Test
  public void process() {
    final TemplateEngine templateEngine = new TemplateEngine();

    final Context context = new Context();
    context.setLocale(Locale.SIMPLIFIED_CHINESE);
    context.setVariable("username", "宋骁");

    ClassLoaderTemplateResolver fileTemplateResolver = new ClassLoaderTemplateResolver();

    templateEngine.setTemplateResolver(fileTemplateResolver);

    String result = templateEngine.process("/templates/hello.html", context);

    log.info(result);
  }
}
